package com.lzxm.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lzxm.constant.DateUtil;
import com.lzxm.dao.UserInfoDao;
import com.lzxm.po.SxInfo;
import com.lzxm.po.User;
import com.lzxm.po.UserInfo;


@Service("userinfoService")
public class UserInfoService {
	
	@Resource
	private UserInfoDao userinfoDao;
	
	public UserInfo getUserInfo(Integer user_id){
		return userinfoDao.findUserByResultMap(user_id);
	}
	
	public void updataUserInfo(UserInfo userinfo)
	{
		userinfoDao.updataUserInfo(userinfo);
	}

	public String selectRole(Integer role_id)
	{
		return userinfoDao.selectRole(role_id);
	}
	
	
	public List<UserInfo> selectUserInfoByName(String username)
	{
		List<UserInfo> list = userinfoDao.selectUserInfoByName(username);
		for(int i= 0; i < list.size(); i++){
			String birth = DateUtil.dateToStr(list.get(i).getBirthday());
			list.get(i).setBirth(birth);
		}
		return list;
	}
}
